package com.ftqh.tutorial.security.oauth2.provider.client;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.Optional;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2017/1/5
 * \* Time: 18:34
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public interface OAuth2ClientDetailsRepository extends JpaRepository<OAuth2ClientDetails, String> {

    Optional<OAuth2ClientDetails> findOneByClientId(String clientId);

    @Transactional
    @Modifying
    @Query("update OAuth2ClientDetails clientDetails set clientDetails.clientSecret = ?2 where clientDetails.clientId = ?1 ")
    int updateClientSecret(String clientId, String clientSecret);
}
